/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: 沈小白 2020-07-22 $
 */
import {
	request
} from './config.js'

/**
 * banner
 * **/

export async function getBanner() {
	return request('/mall/ad/page?page=1&pid=500&size=20') //默认获取第一页
}
/**
 * 广告图
 * */
export async function getAd() {
	return request(`/mall/ad/page?start_pid=500&end_pid=520&page=1&size=20`)
	// /mall/ad/page?end_pid=10&page=1&pid=1&size=1&start_pid=1
}
/*
商品分类下的广告图
其他页面的广告图 根据不同pid获取
*/
export async function getClassifyAd(pid) {
	return request(`/mall/ad/page?page=1&pid=${pid}&size=1`)

}
/*
 *品牌
 */
export async function getBrand(p) {
	return request(`/mall/brand/page?is_hot=1&p=${p}&size=15&status=0`)
}
/*
品牌商品推荐
*/
export async function getBrandRecommend() {
	return request(`/mall/goods/page?is_brand=true`)
}
/*搜索商品*/
export async function searchGoods(params) {
	return request(`/mall/goods/page`, "GET", params)
}
/*
 *商品热门推荐
 */
export async function getRecommendation() {
	return request('/mall/goods/page?is_recommend=1&p=1')
}
/**
 * 商品热销
 */
export async function getGoodsSell(params) {
	return request(`/mall/goods/page?is_hot=1&p=${params.p}&size=10`,'get',)
}
/*积分商城*/
export async function getGoodsIntegral(params) {
	return request(`/mall/goods/page?is_exchange_integral=true`,'get',params)
}

/**
 * 团购商品
 * */
export async function getGroup(p, order) {
	return request(`/mall/group_buy/goods/page?order_by=${order}&sort=false&p=${p}`)
}
/*
店铺推荐商品
*/
export async function getStoreRecommend(id) {
	return request(`/mall/goods/page?cat_id=${id}&size=9`)
}
/*商品列表*/
export async function getGoods(id, p) {
	return request(`/mall/goods/page?cat_id=${id}&p=${p}`)
}
/*品牌查询列*/
export async function getBrandList(id, p) {
	return request(`/mall/goods/page?brand_ids=${id}&size=${p}`)
}


/*店铺商品*/
export async function getStoreGoods(params) {
	return request(`/mall/goods/page`, "GET", params)
}
/*商品筛选*/
export async function getGoodsFilter(url) {
	return request(`/mall/goods/filter_urls?filter_url=/mall/goods/page?${url}`)
}
// /mall/goods/filter_urls?filter_url=/mall/goods/page?cat_id=298&size=9
/*
 *拼团活动列表
 */
export async function getTreamList(params) {
	return request("/mall/team/goods/page", "GET", params)
}
/*拼团活动信息*/
export async function getTreamInfo(id) {
	return request(`/mall/team/activity/${id}`)
}
/*拼主分页
 */
export async function getTreamFound(params) {
	return request(`/mall/team/found/page?&p=${params.p}&size=10&status=${params.status}&team_id=${params.team_id}`)
}
export async function getTreamFollows(params) {
	return request(`/mall/team/follows`, "GET", params)
}
/*拼团下单*/
export async function postTreamOrder(params) {
	return request(`/mall/team/order`, "POST", params)
}
/*拼团订单*/
export async function getTreamOrder(params) {
	return request(`/mall/team/order`, "GET", params)
}
/*提交拼团订单*/
export async function putTreamOrder(params) {
	return request(`/mall/team/order`, "PUT", params)
}
/*拼主团长信息*/
export async function getTreamFoundInfo(params) {
	return request(`/mall/team/found`, "GET", params)
}
/*拼团主体信息*/
export async function getTreamActive(params) {
	return request(`/mall/team/activity/${params}`)
}
/*
 *秒杀活动页面
 * */
export async function getSeckill(params) {
	return request(`/mall/flash_sale/page?end_time=${params.end_time}&recommend=${params.recommend}&p=${params.p}&start_time=${params.start_time}&status=1`, )
}

/*商品主体信息*/
export async function getGoodsInfo(id) {
	return request(`/mall/goods/${id}`)
}

/*商品列表图片*/
export async function getGoodsImg(id) {
	return request(`/mall/goods/image/list?goods_id=${id}&result=%7B%7D`)
}

/*优惠劵信息*/
// export async function getCoupons(id,type){
// 	return request(`/mall/coupons?cat_id=${id}&p=1&size=15&type=${type}`)
// }
export async function getCoupons(params) {
	return request(`/mall/coupon/page`, "GET", params)
}
/*订单优惠列表*/
export async function getPromOrder(id) {
	return request(`/mall/prom_order/list?store_id=${id}`)
}

/*店铺信息*/
export async function getStore(id) {
	return request(`/seller/store?store_id=${id}`)
}

/*商品规格参数属性列表*/
export async function getGoodsAttr(id) {
	return request(`/mall/goods_attr/list?goods_id=${id}`)
}

/*商品评论*/

export async function getComments(id, type, p) {
	return request(`/order/comment/page?goods_id=${id}&type=${type}&p=${p}&size=10`)
}

/*商品评论人数 百分比*/
export async function getCommentStatistics(id) {
	return request(`/order/comment/statistics?goods_id=${id}`)
}

/*商品分类查询列表*/

export async function getGoodsCategoryList(is_level1) {
	return request(`/mall/goods/category/list?level=${is_level1}`)
}
/*商品品牌查询列表*/
export async function getBrandInfo(params) {
	return request(`/mall/brand/list`, "GET", params)
}
/*商品分类下的所有商品*/
export async function getGoodsCategoryProgeny(id) {
	return request(`/mall/goods/category/progeny/${id}`)
}

/**
 * 区域地址
 */
export async function getAddress(id) {
	return request(`/mall/region/list?parent_id=${id}`)
}
/*用户*/
export async function getCity(params) {
	return request(`/mall/region/list?ids=${params.province}&ids=${params.city}&ids=${params.district}`)
}
/*店铺街相关
 */
export async function getStoreStreet(params) {
	return request(`/seller/store/street?p=${params.p}&sc_id=${params.scid}&order_by=${params.order}&city_id=${params.cityId}&sort=desc`)
}
/*店铺分类*/
export async function getStoreClassify() {
	return request(`/seller/store_class/list`)
}

/*商品价格*/
export async function getPrice(id) {
	return request(`/mall/spec_goods_price/list?goods_id=${id}`)
}

/*商品规格*/
export async function getSpecification(id) {
	return request(`/mall/spec/goods?goods_id=${id}`);
}

/*商品sku*/
export async function getSku(params) {
	return request(`/mall/goods/sku?id=${params.id}&is_team=${params.isTeam}&item_id=${params.itemId}`);
}

/*小程序登录 测试*/
export async function wxlogin(params) {
	return request(`/user/login/miniapp?js_code=${params.js_code}&test=${params.test}`, "POST");
}

/*新建用户地址*/
export async function postAddress(params) {
	return request(`/user/address`, "POST", params)
}

/*查询用户地址list */
export async function getUserAddress() {
	return request(`/user/address/list`)
}

/*修改地址*/
export async function putAddress(params) {
	return request(`/user/address`, "PUT", params)
}
/*单个地址*/
export async function getAddressOne(id) {
	return request(`/user/address/${id}`)
}
/*删除地址*/
export async function delAddress(id) {
	return request(`/user/address/${id}`, "DELETE")
}
/*用户信息*/
export async function getUserInfo() {
	return request(`/user/current`)
}

/*h5版注册*/
export async function register(params) {
	return request(`/user/register`, "POST", params)
}
/*h5版登录*/
export async function login(params) {
	return request(`/user/login`, "POST", params)
}

/*h5登录图片验证码*/
export async function verification() {
	return request(`/auth/verification?t=${Math.random()}`)
}

/*查询店铺关注*/
export async function getStoreFocus(storeId) {
	return request(`/user/store_collect/${storeId}`)
}
/*店铺关注*/
export async function storeFocus(storeId) {
	return request(`/user/store_collect/${storeId}`, "POST")
}
/*取消店铺关注*/
export async function delStoreFocus(storeId) {
	return request(`/user/store_collect/${storeId}`, "DELETE")
}
/*店铺商品数量*/
export async function getStoreGoodsCount(storeId) {
	return request(`/mall/store/goods_count?store_id=${storeId}`)
}
/*查询用户商品收藏*/
export async function getGoodsFocus(goodsId) {
	return request(`/mall/goods_collects/?goods_id=${goodsId}`)
}
/*商品收藏*/
export async function postGoodsFocus(goodsId) {
	return request(`/mall/goods_collects/${goodsId}`, "POST")
}
/*商品取消收藏*/
export async function delGoodsFocus(goodsId) {
	return request(`/mall/goods_collects/${goodsId}`, "DELETE")
}

/*用户店铺关注列表*/
export async function getStoreFocusList() {
	return request(`/user/store_collect/list`)
}

/*用户领取优惠劵*/
export async function postCoupon(params) {
	return request(`/mall/user/coupon`, "POST", params)
}
/*用户优惠劵*/
export async function getUserCoupon(params) {
	return request(`/mall/user/coupon/list`, "GET", params)
}

/*用户所有领取的优惠劵*/
export async function getUserCouponList(params) {
	return request(`/mall/user/coupon/page`, "GET", params)
}
/*新人红包*/
export async function getNewcomers() {
	return request(`/mall/user/coupon/new/list`)
}

/*加入购物车*/
export async function addCart(params) {
	return request(`/mall/cart`, "POST", params)
}
/*购物车商品总数*/
export async function getGoodsCartNum() {
	return request(`/mall/cart/goods_count`)
}
/*获取购物车 && 立即购买*/
export async function getCartList(params) {
	return request(`/mall/cart/bill`, "GET", params)
}
/*修改购物车*/
export async function putCartList(params) {
	return request(`/mall/cart/bill`, "PUT", params);
}
/*删除购物车*/
export async function delShopCart(ids) {
	return request(`/mall/cart/${ids}`, "DELETE");
}

/*获取购物车订单*/
export async function getCartOrder(params) {
	return request(`/mall/cart/order`, "GET", params)
}

/*提交订单*/
export async function postCartOrder(params, storeData) {
	return request(`/mall/cart/order?goods_id=${storeData.id}&goods_num=${storeData.num}&item_id=${storeData.itemId}`, "POST", params)
}

/*获取用户发票*/
export async function getInvoice() {
	return request(`/user/user_extend`)
}

/*用户添加发票/修改发票*/
export async function putInvoice(params) {
	return request(`/user/user_extend`, "PUT", params)
}

/*配置*/
export async function getConfig() {
	return request(`/mall/config`)
}
/*获取系统时间*/
export async function getSystemTime() {
	return request(`/mall/system_time`)
}

/*获取主订单*/
export async function getOrder(params) {
	return request(`/order/pay/master_order`, "GET", params)
}

/*订单余额支付*/
export async function payUserMoney(params) {
	return request(`/order/user_money`, "PUT", params)
}

/*订单*/
export async function getOrderPage(params) {
	return request(`/order/user/page`, "GET", params)
}
/*订单评价*/
export async function getComment(params) {
	return request(`/order/order_goods/comment/page`, "GET", params)
}
/*取消订单*/
export async function putCancelOrder(params) {
	return request(`/order/order_status/3`, "PUT", params)
}

/*订单信息*/
export async function getOrderInfo(params) {
	return request(`/order/user`, "GET", params)
}
/*订单商品*/
export async function getOrderGoods(params) {
	return request(`/order/order_goods`,'get',params)
}
/*订单详情 查询订单商品*/
export async function getOrderGoodsList(params){
	return request(`/order/order_goods/list`,'get',params)
}
/*订单收货*/
export async function getTheGoods(params) {
	return request(`/order/order_status/2`, "PUT", params)
}


/*发货物流信息*/
export async function getLogistics(params){
	return request(`/order/delivery_doc/list/user`,'get',params)
}


/*追加商品评价*/
export async function postGoodsComment(params) {
	return request(`/order/comment`, "POST", params)
}

/*添加订单评价*/
export async function postOrderComment(params) {
	return request(`/order/order_comment`, "POST", params)
}

/*修改用户信息*/
export async function putUser(params) {
	return request(`/user/`, "PUT", params)
}

/*修改登录密码*/
export async function putPassword(params) {
	return request(`/user/password`, "PUT", params)
}
/*用户可用优惠券数量*/
export async function getAbleCount() {
	return request(`/mall/user/coupon/able_count`);
}

/*订单统计概况*/
export async function getOrderStatistic() {
	return request(`/order/statistic`)
}

/*访问日志*/
export async function getVisit(params) {
	return request(`/mall/goods/visit/page`, "GET", params)
}
/*删除访问日志*/
export async function delateVisit(params) {
	return request(`/mall/goods/visit?goods_id=${params.goods_id}`,'delete',)
}

/*添加商品浏览记录*/
export async function postVisit(goods_id) {
	return request(`/mall/goods/visit?goods_id=${goods_id}`,'post')
}

/*获取商品运费*/
export async function getFreight(params) {
	return request(`/mall/goods/freight`, "GET", params)
}

/*获取用户分销等级*/
export async function getDistributLevel() {
	return request(`/user/distribut/level`)
}

/*用户提现统计
type:0 余额提现 1 佣金提现
*/
export async function getWithdrawalsCount(type) {
	return request(`/user/withdrawals/count?type=${type}`)
}

/*获取用户下线人数*/
export async function getFollowCount() {
	return request(`/user/follow/count`)
}

/*获取用户下线订单概况*/
export async function getFollowSurvey() {
	return request(`/order/rebate_log/survey`)
}
/*分销提现概况*/
export async function getSurvey() {
	return request(`/user/withdrawals/survey`)
}

/*用户店铺相关*/
export async function getUserStore() {
	return request(`/user/store`)
}

/*添加用户店铺*/
export async function postUserStore(params) {
	return request(`/user/store`, "POST", params)
}
export async function putUserStore(params) {
	return request(`/user/store`, "PUT", params)
}

/*获取系统文章*/
export async function getSystemArticle(params) {
	return request(`/mall/system_article?doc_code=${params}`)
}
/*获取文章接口*/
export async function getArticle(params){
	return request(`/mall/article`,'get',params)
	
} 
/*用户未添加分销商品*/
export async function getDistribution(params) {
	return request(`/mall/distribution/goods/page/not_added`, "GET", params)
}
/*已经添加分销商品*/
export async function getBeenAdd(params) {
	return request(`/mall/distribution/goods/page/added`, "GET", params)
}
/*用户添加分销商品*/
export async function postUerDistribution(params) {
	return request(`/user/distribution/goods/add?goods_id=${params}`, "POST")

}
/*用户删除分销商品*/
export async function delUerDistribution(params) {
	return request(`/user/distribution/goods?goods_id=${params}`, "DELETE")
}
/*用户分销商品统计概况*/
export async function getSurveyCount() {
	return request(`/mall/distribution/goods/survey`)
}

/*分销商品订单*/
export async function getDistributionOrder(params) {
	return request(`/order/rebate_log/order_goods`, "GET", params)
}
/*分销团队 下线人数*/
export async function getLowerCount() {
	return request(`/user/lower/count`, "GET")
}

/*用户第一级下线*/
export async function getFirstLowers(params) {
	return request(`/user/first_lowers`, "GET", params)
}
/*用户二三级下线*/
export async function getLowers(params) {
	return request(`/user/lowers`, "GET", params)
}

/*用户余额日志*/
export async function getAccount(params) {
	return request(`/user/account_log/user_money/page`, "GET", params)
}
/*用户积分日志*/
export async function getPayPoints(params) {
	return request(`/user/account_log/pay_points/page?`, "GET", params)
}

/*订单充值记录*/
export async function getRecharge(params) {
	return request(`/order/recharge/page/user`, "GET", params);
}

/*提现记录*/
export async function getWithdrawals(params) {
	return request(`/user/withdrawals/page`, "GET", params)
}

/*会员签到统计*/
export async function getSign() {
	return request(`/user/sign`)
}
/*会员签到*/
export async function postSign() {
	return request(`/user/sign`, "POST")
}
/*消息条数*/
export async function getMessage(params) {
	return request(`/user/message/tab`, "GET", params)
}
/*通知分页*/
export async function getMessageNotice(params) {
	return request(`/user/message/notice/page`, "GET", params)
}
/*活动分页*/
export async function getMessageActivity(params) {
	return request(`/user/message/activity/page`, "GET", params)
}

/*物流分页*/
export async function getMessageLogistics(params) {
	return request(`/user/message/message/logistics/page`, 'GET', params)
}

/*设置消息已读*/
export async function putMessageSee(recid) {
	return request(`/user/message/is_see?rec_id=${recid}`, "PUT")
}

/*清空消息*/
export async function delMessage(params) {
	return request(`/user/message`, "DELETE", params)
}
/*活动消息*/
export async function getActiveInfo(recid) {
	return request(`/user/message/activity?rec_id=${recid}`)
}
/*通知类消息*/
export async function getNoticeInfo(recid) {
	return request(`/user/message/notice?rec_id=${recid}`)
}

/*店铺入驻相关资料*/
export async function getStoreApply() {
	return request(`/seller/store_apply/user`)
}
/*提交店铺相关资料*/
export async function postStoreApply(params) {
	return request(`/seller/store_apply/user`, "POST", params)
}

/*更新店铺相关资料*/
export async function putStoreApply(params) {
	return request(`/seller/store_apply/user`, "PUT", params)
}

/*店铺分类*/
export async function getStoreClass() {
	return request(`/seller/store_class/list`)
}

/*商品退换货记录*/
export async function getReturnGoods(params) {
	return request(`/order/return_goods?rec_id=${params}`)
}
/*退换货*/
export async function getReturnGoodsPage(params) {
	return request(`/order/return_goods/page/user`, "GET", params)
}

/*申请售后*/
export async function postReturnGoods(params) {
	return request(`/order/return_goods`, "POST", params)
}



/*取消退换货*/
export async function putReturnStatus(params) {
	return request(`/order/return_goods/status/-2?id=${params}`, "PUT", )
}
/*物流?*/
export async function getExpress(params) {
	return request(`/order/delivery_doc/express`, "GET", params)
}

/*退出登录*/
export async function loginOut(params) {
	return request(`/mall/logout`, "POST", params)
}

/*提现 type:0 普通提现  1 佣金提现
 */
export async function postWithdrawal(params) {
	return request(`/user/withdrawals`, "POST", params)
}

/*绑定三方平台列表*/
export async function getOauthList(params) {
	return request(`/user/oauth/list`, "GET", params)
}

/*手机验证码 登录*/
export async function postLoginCode(params) {
	return request(`/user/login`, "post", params)
}

/*验证短信验证码*/
export async function validationSms(params){
	return request(`/user/sms/verification`,'post',params)
} 
/*获取短信验证码*/
export async function sendSms(params){
	return request(`/user/sms/log`,'post',params)
}
/*更改手机号*/ 
export async function putMobile(params){
	return request(`/user/mobile`,'put',params)
}
/*忘记密码*/ 
export async function forgotPassword(params){
	return request(`/user/password/forgot`,'put',params)
}

/*修改支付密码*/
export async function putPaypwd(params){
	return request(`/user/paypwd`,'put',params)
}

/*微信公众号获取授权信息*/
export async function wechatGetInfo(params){
	return request(`/mall/wechat/authorization`,'get',params)
}
/*获取用户授权登录信息*/
export async function getWxUserInfo(params){
	return request(`/mall/wechat/authorization/user_info`,'get',params)
} 
/*获取微信公众号配置信息*/
export async function getWxAppInfo(params){
	return request(`/mall/wx_user`,'get',params)
} 
/*个人中心自定义*/
export async function getMenu(){
	return request(`/mall/menu`,'get')
} 
/*个人收藏分页*/
export async function getCollectList(params){
	return request(`/mall/goods_collect/page`,'get',params)
} 
/*个人店铺收藏分页*/
export async function getStoreCollectList(params){
	return request(`/user/store_collect/user/page`,'get',params)
} 
/*微信支付*/
export async function wxPay(params){
	return request(`/order/unified`,'POST',params)
} 

/*获取平台 open_id*/
export async function getOauth(params){
	return request(`/user/oauth?oauth=${params.oauth}`,'get')
} 
/*查询是否绑定信息*/
export async function getBindInfo(params){
	return request(`/user/oauth/user`,'get',params)
} 